﻿#region Header

// Majesty of Omega - The next evolution of macro management space strategy
// 
// Copyright 2007-2009 André Claaßen
// 
// This file is protected by the terms and conditions of the
// Microsoft Community License (Ms-CL 1.1), a copy of which should
// have been distributed along with this software. If not,
// you may find the license information at the following URL:
// 
// http://www.microsoft.com/resources/sharedsource/licensingbasics/communitylicense.mspx

#endregion

#region

using System.Collections.Generic;
using System.Xml.Serialization;
using DesignByContract;

#endregion

namespace Majesty_of_Omega.Config
{
    /// <summary>
    /// Serverity of a situation report entry
    /// </summary>
    public enum SitReportPriority
    {
        /// <summary>
        /// A green situation report entry reflects a normal or informal status message.
        /// </summary>
        Green,
        /// <summary>
        /// A yellow situation report entry reflects a status message, where the player should consider to react.
        /// </summary>
        Yellow,
        /// <summary>
        /// A red siutation report entry reflects a urgend status message. The play must react.
        /// </summary>
        Red,
        /// <summary>
        /// A special event, like a battle, or an event.
        /// </summary>
        Special
    }


    /// <summary>
    /// Type of the situation report
    /// </summary>
    public enum SitReportType
    {
        /// <summary>
        /// Turn completed message
        /// </summary>
        TurnCompleted,
        /// <summary>
        /// test entry
        /// </summary>
        TurnCompletedTest,

        /// <summary>
        /// Entering of a new Tech level
        /// </summary>
        ResearchBreakthroughOnField,

        /// <summary>
        /// Unlock a new technology field
        /// </summary>
        ResearchUnlockTechField,

        /// <summary>
        /// Uncovered a new technology
        /// </summary>
        NewTechnologyUncovered,

        /// <summary>
        /// Start of a new research project
        /// </summary>
        TechnologyProjectResearchStarted,

        /// <summary>
        /// Application technology fully researched and available
        /// </summary>
        TechnologyProjectResearched,

        /// <summary>
        /// Technology reached the prototyping state
        /// </summary>
        TechnologyReachedPrototypeState,

        /// <summary>
        /// Technology leads to a positive overrun
        /// </summary>
        TechnologyProjectResearchedWithPositiveOverrun,

        /// <summary>
        /// Technology research hits a Roadblock
        /// </summary>
        TechnologyProjectRoadblockOccured
    }

    /// <summary>
    /// The SitReportTable.xml container class
    /// </summary>
    [XmlType(AnonymousType = true, Namespace = "http://majesty-of-omega/SitReport.xsd")]
    [XmlRoot(Namespace = "http://majesty-of-omega/SitReport.xsd", IsNullable = false)]
    public class SitReportTable : Spreadsheet
    {
        /// <remarks/>
        [XmlElement("SitReportEvent")]
        public List<SitReportEvent> SitReportEventEntries { get; set; }

        /// <summary>
        /// Gets the report event with the given type
        /// </summary>
        /// <param name="type">The type.</param>
        public SitReportEvent GetReportEvent(SitReportType type)
        {
            SitReportEvent reportEvent = SitReportEventEntries.Find(entry => entry.Type_ID == type);
            Ensure.IsNotNull(reportEvent, string.Format("There is no event entry for the given type {0}", type));
            return reportEvent;
        }
    }

    /// <summary>
    /// An entry in the SitReportTable
    /// </summary>
    [XmlType(AnonymousType = true, Namespace = "http://majesty-of-omega/SitReport.xsd")]
    public class SitReportEvent
    {
        /// <summary>
        /// The unique Type_ID of this sitreport entry
        /// </summary>
        /// <value>The type_ ID.</value>
        /// <remarks/>
        [XmlAttribute]
        public SitReportType Type_ID { get; set; }

        /// <summary>
        /// Gets or sets the priority of the situation report
        /// </summary>
        /// <value>The priority.</value>
        /// <remarks/>
        [XmlAttribute]
        public SitReportPriority Priority { get; set; }

        /// <summary>
        /// Gets or sets the Icon
        /// </summary>
        /// <value>The name of the icon without path and .png extension</value>
        /// <remarks/>
        [XmlAttribute]
        public string Icon { get; set; }

        /// <summary>
        /// Gets or sets the ID of the description text in the string table
        /// </summary>
        /// <value>The description_ ID.</value>
        /// <remarks/>
        [XmlAttribute]
        public string Description_ID { get; set; }

        /// <summary>
        /// Gets the description of the situation report item
        /// </summary>
        /// <value>The description.</value>
        public string Description
        {
            get { return StringManager.GetString(Description_ID); }
        }
    }
}